home *** CD-ROM | disk | FTP | other *** search
/ IRIX 5.3 for Indy R4400 / IRIX 5.3 for Indy R4400 175MHz.img / dist / eoe2.idb / usr / lib / acct / dodisk.z / dodisk
Text File  |  1995-02-28  |  5KB  |  263 lines

  1. #!/sbin/sh
  2. #    Copyright (c) 1993 UNIX System Laboratories, Inc.
  3. #      All Rights Reserved
  4.  
  5. #    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF
  6. #    UNIX System Laboratories, Inc.       
  7. #    The copyright notice above does not evidence any
  8. #    actual or intended publication of such source code.
  9.  
  10. #    copyright    "%c%"
  11.  
  12. #ident    "@(#)acct:common/cmd/acct/dodisk.sh    1.13.2.7"
  13. #ident "$Header: /proj/irix5.3/isms/irix/cmd/acct/RCS/dodisk.sh,v 1.6 1994/03/04 23:28:26 nawaf Exp $"
  14. # 'perform disk accounting'
  15. PATH=/usr/lib/acct:/bin:/usr/bin:/etc:
  16. export PATH
  17. _dir=/var/adm
  18. _pickup=acct/nite
  19.  
  20. set -- `getopt o $*`
  21. if [ $? -ne 0 ]
  22. then
  23.     echo "Usage: $0 [ -o ] [ filesystem ... ]"
  24.     exit 1
  25. fi
  26. for i in $*; do
  27.     case $i in
  28.     -o)    SLOW=1; shift;;
  29.     --)    shift; break;;
  30.     esac
  31. done
  32.  
  33. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  34. # Some systems may not use /etc/vfstab to store mount information #
  35. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
  36. DEVLIST=/etc/fstab
  37. format="special mnt fstype attrs"
  38. if [ ! -f "$DEVLIST"  -a  "$SLOW" = "" ]
  39. then
  40.     echo "$DEVLIST does not exist: Use -o option"
  41.     echo "Usage: $0 [ -o ] [ filesystem ... ]"
  42.     exit 2
  43. fi
  44.  
  45. cd ${_dir}
  46.  
  47. if [ "$SLOW" = "" ]
  48. then
  49.     if [ $# -lt 1 ]
  50.     then
  51.     # Do disk accting for file systems in DEVLIST
  52.         while :
  53.         do
  54.             if read $format
  55.                    then
  56.                 dev=$special
  57.                 if [ "$dev" = "" -o "$mnt" = "" ]
  58.                 then
  59.                     continue;
  60.                 fi
  61.                 if [ `expr $dev : '\(.\)'` = \# ]
  62.                        then
  63.                                continue
  64.                     fi
  65.                 if [ "$fstype" = efs ]
  66.                 then
  67.                     diskusg $dev > `basename $dev`.dtmp &
  68.                     continue
  69.                 fi
  70.                 #if [ "$fstype" = s5 ]
  71.                 #then
  72.                     #diskusg $dev > `basename $dev`.dtmp &
  73.                     #continue
  74.                 #fi
  75.                 #if [ "$fstype" = bfs ]
  76.                 #then
  77.                     #bfsdiskusg $dev > `basename $dev`.dtmp &
  78.                     #continue
  79.                 #fi
  80.                 #if [ "$fstype" = ufs ]
  81.                 #then
  82.                     #ufsdiskusg $dev > `basename $dev`.dtmp &
  83.                     #continue
  84.                 #fi
  85.                 #if [ "$fstype" = sfs ]
  86.                 #then
  87.                     #sfsdiskusg $dev > `basename $dev`.dtmp &
  88.                     #continue
  89.                 #fi
  90.                 #if [ "$fstype" = vxfs ]
  91.                 #then
  92.                     #vxdiskusg $dev > `basename $dev`.dtmp &
  93.                     #continue
  94.                 #fi
  95.                 # rfs and nfs fstypes not done 
  96.                 if [ "$fstype" = rfs ]
  97.                 then
  98.                     continue
  99.                 fi
  100.                 if [ "$fstype" = nfs ]
  101.                 then
  102.                     continue
  103.                 fi
  104.                 if [ "$fstype" = afs ]
  105.                 then
  106.                     continue
  107.                 fi
  108.                 if [ "$fstype" = swap ]
  109.                 then
  110.                     continue
  111.                 fi
  112.                 # fs is none of the above so use slow method
  113.                 find $mnt -print | acctdusg > `basename $dev`.dtmp &
  114.             else
  115.                 wait
  116.                 break
  117.             fi
  118.         done < $DEVLIST
  119.         cat *.dtmp | diskusg -s > dtmp
  120.         rm -f *.dtmp
  121.     else
  122.     # do only those file systems in arg list
  123.         args="$*"
  124.         for i in $args; do
  125.             fstype=`fstyp $i`
  126.             # sort args by fstype
  127.             if [ "$fstype" = efs ]
  128.             then
  129.                 efs="$efs $i"
  130.                 continue
  131.             fi
  132.             #if [ "$fstype" = s5 ]
  133.             #then
  134.                 #s5="$s5 $i"
  135.                 #continue
  136.             #fi
  137.             #if [ "$fstype" = bfs ]
  138.             #then
  139.                 #bfs="$bfs $i"
  140.                 #continue
  141.             #fi
  142.             #if [ "$fstype" = sfs ]
  143.             #then
  144.                 #sfs="$sfs $i"
  145.                 #continue
  146.             #fi
  147.             #if [ "$fstype" = ufs ]
  148.             #then
  149.                 #ufs="$ufs $i"
  150.                 #continue
  151.             #fi
  152.             #if [ "$fstype" = vxfs ]
  153.             #then
  154.                 #vxfs="$vxfs $i"
  155.                 #continue
  156.             #fi
  157.             # don't do rfs, nfs, afs and swap
  158.             if [ "$fstype" = rfs ]
  159.             then
  160.                 continue
  161.             fi
  162.             if [ "$fstype" = nfs ]
  163.             then
  164.                 continue
  165.             fi
  166.             if [ "$fstype" = afs ]
  167.             then
  168.                 continue
  169.             fi
  170.             if [ "$fstype" = swap ]
  171.             then
  172.                 continue
  173.             fi
  174.             
  175.             # all other file system types are done via acctdusg
  176.             #mnt=`df -n $i 2>/dev/null | cut -f 1 -d " "`
  177.             mnt=`mount |grep $i | awk '{print $3}'`
  178.             if [ -n "$mnt" ]
  179.             then
  180.                 other="$other $mnt"
  181.             else
  182.                 # df only gets mount name for /dev/dsk
  183.                 dirname=`dirname $i`
  184.                 if [ "$dirname" = "/dev/rdsk" ]
  185.                 then
  186.                     basename=`basename $i`
  187.                     #mnt=`df -n "/dev/dsk/"${basename} 2>/dev/null | cut -f 1 -d " "`
  188.                     mnt=`mount |grep /dev/dsk/${basename} | awk '{print $3}'`
  189.                 fi
  190.                 if [ -n "$mnt" ]
  191.                 then
  192.                     other="$other $mnt"
  193.                 else
  194.                     echo "dodisk: $i not done.  Bad name or not mounted."
  195.                 fi
  196.             fi
  197.         done
  198.         #if [ -n "$s5" ]
  199.         #then
  200.             #diskusg $s5 > dtmp1 &
  201.         #fi
  202.         #if [ -n "$bfs" ]
  203.         #then
  204.             #bfsdiskusg $bfs > dtmp2 &
  205.         #fi
  206.         #if [ -n "$sfs" ]
  207.         #then
  208.             #sfsdiskusg $sfs > dtmp3 &
  209.         #fi
  210.         #if [ -n "$ufs" ]
  211.         #then
  212.             #ufsdiskusg $ufs > dtmp4 &
  213.         #fi
  214.         #if [ -n "$vxfs" ]
  215.         #then
  216.             #vxdiskusg $vxfs > dtmp5 &
  217.         #fi
  218.         if [ -n "$other" ]
  219.         then
  220.             find $other -print | acctdusg > dtmp6 &
  221.         fi
  222.         if [ -n "$efs" ]
  223.         then
  224.             diskusg $efs > dtmp7 &
  225.         fi
  226.         wait
  227.         cat dtmp[1-7] | diskusg -s > dtmp
  228.         rm dtmp[1-7]
  229.     fi
  230. else
  231.     if [ $# -lt 1 ]
  232.     then
  233.         args="/"
  234.     else
  235.         args="$*"
  236.     fi
  237.     for i in $args; do
  238.         if [ ! -d $i ]
  239.         then
  240.             echo "$0: $i is not a directory -- ignored"
  241.         else
  242.             dir="$i $dir"
  243.         fi
  244.     done
  245.     if [ "$dir" = "" ]
  246.     then
  247.         echo "$0: No data"
  248.         > dtmp
  249.     else
  250.         find $dir -print | acctdusg > dtmp
  251.     fi
  252. fi
  253.  
  254. sort +0n +1 dtmp | acctdisk > ${_pickup}/disktacct 2>dodiskerr
  255. if [ -s dodiskerr ]
  256. then
  257.     cat dodiskerr > /dev/conslog
  258.     mail adm root <dodiskerr
  259.     rm -f dodiskerr
  260. fi
  261. chmod 644 ${_pickup}/disktacct
  262. chown adm ${_pickup}/disktacct
  263.